home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / YICN23.ZIP / DEMO / SOURCE.ZIP / STARS.CPP < prev    next >
C/C++ Source or Header  |  1993-02-28  |  3KB  |  94 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <alloc.h>
  5. #include "xlib.h"
  6. #include "xrect.h"
  7. #include "icon.h"
  8. #include "animicon.h"
  9. #include "yakFont.h"
  10. #include "yakMouse.h"
  11. #include "yakPal.h"
  12.  
  13. class star
  14. {
  15. public:
  16.   int x, y, xIncrement, yIncrement, size;
  17.   void initialize(void) {x = 100 + random(100); y = 60 + random(60); size = 5;};
  18.   void advance(void);
  19.   star(void) {initialize();};
  20. };
  21.  
  22. void star::advance(void)
  23. {
  24.   xIncrement = (x - 150)/5;
  25.   yIncrement = (y-100)/5;
  26.   x+=xIncrement;
  27.   y+=yIncrement;
  28.   size++;
  29.   if ((x < 0) || (x+size > 320)) initialize();
  30.   if ((y < 0) || (y+size > 200)) initialize();
  31. };
  32.  
  33. extern yakLib myYakLib;
  34. extern yakFont myYakFont;
  35.  
  36. void stars(void)
  37. {
  38.   randomize();
  39.   icon starIcon, logoIcon;
  40.   animicon shipIcon;
  41.   icon::setZoomTable(64);
  42.   x_set_doublebuffer(200);
  43.   x_text_init();
  44.   myYakFont.use();
  45.   yakPalette myYakPalette("standard.ypl", &myYakLib);
  46.   myYakPalette.put();
  47.   starIcon.load("star.yak", icon::normal, &myYakLib);
  48.   shipIcon.addAll("awayship", icon::normal, &myYakLib);
  49.   logoIcon.load("yicons.yak", icon::normal, &myYakLib);
  50.   int shipX, logoX, y, exit = 0;
  51.   int shipScale=200, logoScale = 1;
  52.   shipX = 50, logoX = 150;
  53.   star stars[10];
  54.   while ((exit != 'Q') && (shipScale > 0))
  55.   {
  56.     x_rect_fill(0,0,320,200,HiddenPageOffs,0);
  57.     for (int starCounter = 0; starCounter < 10; ++starCounter)
  58.     {
  59.       stars[starCounter].advance();
  60.       starIcon.showZoomed(stars[starCounter].x, stars[starCounter].y, HiddenPageOffs, stars[starCounter].size);
  61.     }
  62.     shipScale-=4;
  63.     shipX += 2;
  64.     logoScale += 4;
  65.     logoX -= 2;
  66.     if (shipScale > 1)
  67.       shipIcon.showZoomed(shipX, 20, HiddenPageOffs, shipScale);
  68.     if (logoScale > 1)
  69.       logoIcon.showZoomed(logoX, 20, HiddenPageOffs, logoScale);
  70.  
  71.     x_page_flip(0,0);
  72.   }
  73.   icon * logoIconPointer = logoIcon.zoomedIcon(logoScale);
  74.   while (exit != 27)
  75.   {
  76.     x_rect_fill(0,0,320,200,HiddenPageOffs,0);
  77.     for (int starCounter = 0; starCounter < 10; ++starCounter)
  78.     {
  79.       stars[starCounter].advance();
  80.       starIcon.showZoomed(stars[starCounter].x, stars[starCounter].y, HiddenPageOffs, stars[starCounter].size);
  81.     }
  82.     logoIconPointer->showMasked(logoX, 20, HiddenPageOffs);
  83.     x_printf(72, 170, HiddenPageOffs, 15, "Press escape to begin demo");
  84.     x_page_flip(0,0);
  85.     if (kbhit())
  86.       exit = getch();
  87.   }
  88.   for (int counter = 0; counter < 25; ++counter)
  89.   {
  90.     myYakPalette.fade(-5);
  91.     myYakPalette.put();
  92.   }
  93.   delete logoIconPointer;
  94. }